package com.ymm.controller;

import com.ymm.domain.vo.ResponseResult;
import com.ymm.service.YmmFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * @author 椰咩咩咩
 * @version 1.0-SNAPSHOT
 * @date 2023/3/31 12:51
 * @Description
 */
@RestController
@RequestMapping("/ymm")
public class FileController {

    @Autowired
    private YmmFileService ymmFileService;

    @PostMapping("/upload")
    public ResponseResult upload(MultipartFile file) {
        return ResponseResult.okResult(ymmFileService.upload(file));
    }

    @GetMapping("/download/{uuid}")
    public void download(@PathVariable String uuid, HttpServletResponse response) {
        ymmFileService.download(uuid, response);
    }

}
